The present invention relates to a device and method for debugging systems that are controlled by microprocessors, and, more particularly, to a device and method for interactive debugging of systems used in embedded applications.
A wide variety of methods and systems is available for the interactive debugging of most application software for programmable computers. Modern compilers typically include facilities for compiling and linking source code in "debug mode", in which the compilers and linkers produce executable code that can be run interactively. Debugging facilities for testing such code typically enable programmers to set break conditions, to inspect and modify the values of program variables, and to add patches to the code.
Despite the superficial similarity between programmable computers, on the one hand, and systems such as fax machines that are controlled by microprocessors, on the other--both operate under the control of microprocessors that execute stored programs--the software-based debugging facilities that are available for systems controlled by microprocessors are far less flexible than those available for programmable computers. In a programmable computer, which stores its executable code in RAM, the "debug-mode" executable code is created from the source code by a separate debugging program that compiles the source code and replaces the operational code in RAM with the debug-mode code. The user is able to stop the execution of the debug-mode code and modify the debug-mode code at will. In a microprocessor-controlled system, however, the debug-mode code usually is included in the executable code along with the operational code. This executable code often is stored in read-only memory, for example, flash memory or EEPROM, and cannot be modified easily. Furthermore, debug-mode code typically runs slower than operational code. This makes it difficult to reproduce some bugs of real-time systems: a timing conflict that arises in the system when it is operated using relatively fast operational code may not arise when the system is operated using relatively slow debug-mode code.
If the system's microprocessor has a trace mode, the system can be run interactively without a need for debug-mode code accompanying the operational code. If the trace mode is enabled, then, after every step or branch of the operational program, a debug routine is called. This, however, typically is even slower than running debug-mode code, and therefore is even less suitable for debugging real-time systems.
A partial, hardware-based solution to this problem is provided by processor emulators. These are special-purpose computers that emulate the system microprocessors. A processor emulator is plugged into the system's circuit board in place of the microprocessor. The system then can be operated normally, except that the processor emulator, being a true computer and not just a microprocessor, allows monitoring in detail, and in real time, of the actions of the emulated microprocessor.
Processor emulators suffer from certain drawbacks not present in software-based debugging facilities. Processor emulators typically are not as flexible as software-based debugging facilities. One example of this inflexibility is that, because a processor emulator only tracks the current state of the system bus, it cannot monitor as wide a variety of conditions as a software-based debugger. In particular, a processor emulator cannot monitor logical conditions, i.e., conditions that depend on earlier events rather than on the current state of the bus. For example, a processor emulator cannot perform an action like starting a bus trace conditional on the value that was stored some time in the past in a location in memory, as opposed of a value that is being presently stored and therefore is present on the bus. A processor emulator also has no access to the contents of internal registers. Processor emulators cannot be used easily with circuit boards based on surface-mounted technology, in which the system microprocessor cannot be unplugged. A processor emulator typically is specific to a particular version of a microprocessor running at a particular clock rate, and cannot be used to emulate a different version of-the same microprocessor running at a different rate. Finally, processor emulators are expensive, and there is no commonly accepted standard for their design and use.
There is thus a widely recognized need for, and it would be highly advantageous to have, a device and method for interactively debugging microprocessor-operated systems that combines facilities more similar to those available for the software-based debugging of application programs for programmable computers with those available using processor emulators.